package com.sjy.project.ent.yearSta.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sjy.framework.aspectj.lang.annotation.Log;
import com.sjy.framework.aspectj.lang.enums.BusinessType;
import com.sjy.project.ent.yearSta.domain.TEntAssess;
import com.sjy.project.ent.yearSta.service.ITEntAssessService;
import com.sjy.framework.web.controller.BaseController;
import com.sjy.framework.web.domain.AjaxResult;
import com.sjy.common.utils.poi.ExcelUtil;
import com.sjy.framework.web.page.TableDataInfo;

/**
 * 企业评价视图Controller
 * 
 * @author ljb
 * @date 2022-07-09
 */
public class TEntAssessController extends BaseController
{
    private String prefix = "ent/yearSta";

    @Autowired
    private ITEntAssessService tEntAssessService;

    @RequiresPermissions("ent:yearSta:view")
    @GetMapping()
    public String yearSta()
    {
        return prefix + "/yearSta";
    }

    /**
     * 查询企业评价视图列表
     */
    @RequiresPermissions("ent:yearSta:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TEntAssess tEntAssess)
    {
        startPage();
        List<TEntAssess> list = tEntAssessService.selectTEntAssessList(tEntAssess);
        return getDataTable(list);
    }

    /**
     * 导出企业评价视图列表
     */
    @RequiresPermissions("ent:yearSta:export")
    @Log(title = "企业评价视图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TEntAssess tEntAssess)
    {
        List<TEntAssess> list = tEntAssessService.selectTEntAssessList(tEntAssess);
        ExcelUtil<TEntAssess> util = new ExcelUtil<TEntAssess>(TEntAssess.class);
        return util.exportExcel(list, "企业评价视图数据");
    }

    /**
     * 新增企业评价视图
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存企业评价视图
     */
    @RequiresPermissions("ent:yearSta:add")
    @Log(title = "企业评价视图", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TEntAssess tEntAssess)
    {
        return toAjax(tEntAssessService.insertTEntAssess(tEntAssess));
    }

    /**
     * 修改企业评价视图
     */
    @RequiresPermissions("ent:yearSta:edit")
    @GetMapping("/edit/{town}")
    public String edit(@PathVariable("town") String town, ModelMap mmap)
    {
        TEntAssess tEntAssess = tEntAssessService.selectTEntAssessByTown(town);
        mmap.put("tEntAssess", tEntAssess);
        return prefix + "/edit";
    }

    /**
     * 修改保存企业评价视图
     */
    @RequiresPermissions("ent:yearSta:edit")
    @Log(title = "企业评价视图", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TEntAssess tEntAssess)
    {
        return toAjax(tEntAssessService.updateTEntAssess(tEntAssess));
    }

    /**
     * 删除企业评价视图
     */
    @RequiresPermissions("ent:yearSta:remove")
    @Log(title = "企业评价视图", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tEntAssessService.deleteTEntAssessByTowns(ids));
    }
}
